var arr = [];
var count = 5;
var page = 1;

$.ajax({
    url: '/api/dorm/getdorm',
    success: function (res) {
        console.log(res);
        if (res.data.length) {
            arr = res.data;
            rem();
            ret();
        }
    }
})
function rem() {
    $('.motaikuang table tbody').html('');
    $.each(arr.slice((page - 1) * count, page * count), function (i, v) {
        var n = v.type == '1' ? '正常' : '催款中';
        $('.motaikuang table tbody').append(' <tr>\
                    <td class="th1">'+ v.dormId + '</td>\
                    <td>'+ v.dormName + '</td>\
                    <td>'+ v.num + '</td>\
                    <td>'+ v.balance + '</td>\
                    <td>'+ n + '</td>\
                    <td>\
                            <button type="button" class="shu" data-toggle="modal" data-target="#myModal5">\
                                删除\
                            </button>\
                            <button type="button" class="shu" data-toggle="modal" data-target="#exampleModal5"\
                                data-whatever="@mdo">修改</button>\
                            <button type="button" class="shui" data-toggle="modal" data-target="#Modal5">\
                                发起催款申请\
                    </td>\
                </tr>')
    })
}
$('#nav2').on('click', 'li', function () {
    page = $(this).text();
    rem();
})
// 创建页码

function ret() {
    var n = Math.ceil(arr.length / count);
    for (var i = 1; i <= n; i++) {
        $('.yeshu').before($('<li><a href="#">' + i + '</a></li>'));
    }

}
//